﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:drawing="clr-namespace:System.Drawing;assembly=System.Drawing"
                    xmlns:local="clr-namespace:Atdl4net.Wpf.View.Controls"
                    xmlns:resources="clr-namespace:Atdl4net.Wpf.View"
                    xmlns:viewmodel="clr-namespace:Atdl4net.Wpf.ViewModel">

    <!-- Styling to support mandatory fields and validity status -->
    <Style TargetType="local:ClickSelectTextBox">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsRequiredParameter}" Value="True">
                <Setter Property="Background"  Value="MistyRose"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="Foreground" Value="Red"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="ComboBox">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsRequiredParameter}" Value="True">
                <Setter Property="Background"  Value="MistyRose"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Foreground" Value="Red"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="local:TimePicker">
        <Setter Property="BorderThickness" Value="1"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="Foreground" Value="Red"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="True">
                <Setter Property="BorderBrush" Value="LightSlateGray"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="local:Slider">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsRequiredParameter}" Value="True">
                <Setter Property="Background"  Value="MistyRose"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="Foreground" Value="Red"/>
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="BorderThickness" Value="1"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="local:SingleSpinner">
        <Setter Property="BorderThickness" Value="1"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="Foreground" Value="Red"/>
                <Setter Property="BorderBrush" Value="Red"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="True">
                <Setter Property="BorderBrush" Value="LightSlateGray"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="local:DoubleSpinner">
        <Setter Property="BorderThickness" Value="1"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="Foreground" Value="Red"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="True">
                <Setter Property="BorderBrush" Value="LightSlateGray"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="{x:Type ListBoxItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsRequiredParameter}" Value="True">
                <Setter Property="Background" Value="MistyRose"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
    <Style TargetType="ListBox">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="Foreground" Value="Red"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type ItemsControl}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ItemsControl}">
                    <Border CornerRadius="2" BorderBrush="Blue">
                        <ScrollViewer HorizontalScrollBarVisibility="Auto">
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MultiSelectListItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
        <Setter Property="Content" Value="{Binding Path=UiRep}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsRequiredParameter}" Value="True">
                <Setter Property="Background" Value="MistyRose"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type local:CheckBoxList}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate DataType="{x:Type viewmodel:ListItemViewModel}">
                    <StackPanel>
                        <CheckBox Margin="5" Content="{Binding Path=UiRep}"  IsChecked="{Binding Path=IsSelected}" AutomationProperties.AutomationId="{Binding AutomationId}"/>
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:CheckBoxList}">
                    <Border Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              CornerRadius="{TemplateBinding CornerRadius}">
                        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
                            <StackPanel Orientation="{TemplateBinding Orientation}" IsItemsHost="True"/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsRequiredParameter}" Value="True">
                <Setter Property="Background"  Value="MistyRose"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Foreground" Value="Red"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type local:RadioButtonList}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate DataType="{x:Type viewmodel:ListItemViewModel}">
                    <StackPanel>
                        <RadioButton Margin="5" Content="{Binding Path=UiRep}" IsChecked="{Binding Path=IsSelected}" GroupName="{Binding Path=GroupName}" AutomationProperties.AutomationId="{Binding AutomationId}"/>
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:RadioButtonList}">
                    <Border Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              CornerRadius="{TemplateBinding CornerRadius}">
                        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
                            <StackPanel Orientation="{TemplateBinding Orientation}" IsItemsHost="True"/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=IsRequiredParameter}" Value="True">
                <Setter Property="Background"  Value="MistyRose"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=IsValid}" Value="False">
                <Setter Property="BorderBrush" Value="Red"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Foreground" Value="Red"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="StrategyPanelToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid SnapsToDevicePixels="False" Background="Transparent">
                        <Ellipse HorizontalAlignment="Center" x:Name="circle" VerticalAlignment="Center" Width="15" Height="15" Fill="{DynamicResource ButtonNormalBackgroundFill}" Stroke="LightCoral"/>
                        <Ellipse Visibility="Hidden" HorizontalAlignment="Center" x:Name="shadow" VerticalAlignment="Center" Width="13" Height="13" Fill="{DynamicResource ExpanderShadowFill}"/>
                        <Path SnapsToDevicePixels="false" x:Name="arrow" VerticalAlignment="Center" HorizontalAlignment="Center" Stroke="#666" StrokeThickness="2" Data="M1,1 L4,4 7,1" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Data" TargetName="arrow" Value="M 1,4  L 4,1  L 7,4"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Stroke" TargetName="circle" Value="#666"/>
                            <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                            <Setter Property="Visibility" TargetName="shadow" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="StrategyPanelBorderBrush" Color="#D0D0BF"/>
    <SolidColorBrush x:Key="StrategyPanelHeaderBrush" Color="#0046D5"/>
    <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/>

    <Style TargetType="{x:Type local:StrategyPanelFrame}">
        <Setter Property="BorderBrush" Value="{StaticResource StrategyPanelBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:StrategyPanelFrame}">
                    <Grid SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="6" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="6" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="6" />
                        </Grid.RowDefinitions>
                        <Border CornerRadius="3" Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" Background="{TemplateBinding Background}" />
                        <ContentPresenter x:Name="ExpandSite" Visibility="Collapsed" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Border Grid.Row="1" Grid.RowSpan="3" Grid.ColumnSpan="4" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Visibility="{TemplateBinding BorderVisibility}" CornerRadius="3">
                            <Border.OpacityMask>
                                <MultiBinding Converter="{StaticResource BorderGapMaskConverter}" ConverterParameter="7">
                                    <Binding Path="ActualWidth" ElementName="Header"/>
                                    <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/>
                                    <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/>
                                </MultiBinding>
                            </Border.OpacityMask>
                        </Border>
                        <Border x:Name="Header" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Padding="3,0,3,0" Visibility="{TemplateBinding HeaderVisibility}">
                            <Grid SnapsToDevicePixels="False" Background="Transparent" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <ToggleButton Grid.Column="0" MinHeight="0" MinWidth="0"
                Name="HeaderToggle" Style="{StaticResource StrategyPanelToggleButtonStyle}"
                IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                Visibility="{TemplateBinding CollapseButtonVisibility}" >
                                </ToggleButton>
                                <ContentPresenter ContentSource="Header" RecognizesAccessKey="true"
                TextElement.Foreground="{StaticResource StrategyPanelHeaderBrush}"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="3,0,0,0"/>
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="CollapseButtonVisibility" Value="Collapsed"/>
                                <Condition Property="HeaderVisibility" Value="Collapsed"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Padding" Value="0,8,0,0"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>